//
//  RKLogisticsInfoController.m
//  runkang
//
//  Created by 张艳江 on 2018/9/6.
//  Copyright © 2018年 张艳江. All rights reserved.
//

#import "SCLogisticsInfoController.h"
#import "SCWuliuHeaderView.h"
#import "SCWuliuCell.h"

@interface SCLogisticsInfoController ()

@property (strong, nonatomic) NSArray           *dataArray;
@property (strong, nonatomic) SCWuliuHeaderView *headerView;

@end

@implementation SCLogisticsInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"查看物流";
    self.tableView.backgroundColor = BGColor;
    self.tableView.separatorColor = [UIColor clearColor];
    
    [self.tableView registerClass:[SCWuliuCell class] forCellReuseIdentifier:@"WuliuCell"];
    
    //请求数据
    [self requestData];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    SCWuliuCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WuliuCell"];
    SCModel *model = self.dataArray[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row == 0) {
        model.wuliuCellPosition = WuliuCellPositionTop;
    }else if (indexPath.row == self.dataArray.count - 1){
        model.wuliuCellPosition = WuliuCellPositionTail;
    }else {
        model.wuliuCellPosition = WuliuCellPositionMid;
    }
    cell.model = model;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    SCModel *model = self.dataArray[indexPath.row];
    if (model.rowHeight > 0) {
        return model.rowHeight;
    }
    SCWuliuCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WuliuCell"];
    cell.model = model;
    return model.rowHeight;
}
#pragma mark - 请求数据
- (void)requestData{
    
//    NSDictionary *dict = @{@"code":self.model.logi_code,
//                           @"no":self.model.logi_no};
//    [SVProgressHUD showWithStatus:@"加载中..."];
//    [[NetworkRequestTool sharedNetworkTool]requestWithMethod:CGNetworkMethodPOST URLString:HTTP_URL parameters:dict finished:^(id result, NSString *error) {
//
//        [SVProgressHUD dismiss];
//        self.dataArray = [JSModel mj_objectArrayWithKeyValuesArray:result[@"data"][@"info"][@"data"]];
//        [self.tableView reloadData];
//        self.headerView = [SCWuliuHeaderView addHeaderView];
//        self.headerView.frame = CGRectMake(0, 0, kScreenW, 70);
//        self.tableView.tableHeaderView = self.headerView;
//        self.headerView.wuliuCompanyLab.text = [NSString stringWithFormat:@"物流公司：%@", self.model.logi_name];
//        self.headerView.kudiNumLab.text = [NSString stringWithFormat:@"快递单号：%@", self.model.logi_no];
//    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
